package cn.fintecher.gis.respository;

import cn.fintecher.gis.entity.GrantInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Auther: xiaqun
 * @Description:
 * @Date: 17:32 2019/4/29
 */
public interface GrantInfoRepository extends JpaRepository<GrantInfo, String>, QuerydslPredicateExecutor<GrantInfo> {

    @Query(value = "select sum(acreage) as area,to_char(grant_time,'yyyy') as applyTime,unit from grant_info where id in(:ids) GROUP BY applyTime,unit", nativeQuery = true)
    public Object[] getStaticalGrantInfoByYear(@Param("ids") List<String> ids);

}
